package com.youkeda.yikao.web.dao;

import com.youkeda.yikao.web.dataobject.ZhangyankunSpringUser;

import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

@Mapper
public interface ZhangyankunSpringUserMapper {
    @Delete({
            "delete from zhangyankun_spring_user",
            "where email = #{email,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String email);

    @Insert({
            "insert into zhangyankun_spring_user (email, name, ",
            "psd, creat_time, ",
            "modif_time, domain)",
            "values (#{email,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, ",
            "#{psd,jdbcType=VARCHAR}, now(), ",
            "now(), #{domain,jdbcType=VARCHAR})"
    })
    int insert(ZhangyankunSpringUser record);

    @Select({
            "select",
            "email, name, psd, creat_time, modif_time, domain",
            "from zhangyankun_spring_user",
            "where email = #{email,jdbcType=VARCHAR}"
    })
    @Results({
            @Result(column = "email", property = "email", jdbcType = JdbcType.VARCHAR, id = true),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "psd", property = "psd", jdbcType = JdbcType.VARCHAR),
            @Result(column = "creat_time", property = "creatTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "modif_time", property = "modifTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "domain", property = "domain", jdbcType = JdbcType.VARCHAR)
    })
    ZhangyankunSpringUser selectByPrimaryKey(String name);

    @Select({
            "select",
            "email, name, psd, creat_time, modif_time, domain",
            "from zhangyankun_spring_user"
    })
    @Results({
            @Result(column = "email", property = "email", jdbcType = JdbcType.VARCHAR, id = true),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "psd", property = "psd", jdbcType = JdbcType.VARCHAR),
            @Result(column = "creat_time", property = "creatTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "modif_time", property = "modifTime", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "domain", property = "domain", jdbcType = JdbcType.VARCHAR)
    })
    List<ZhangyankunSpringUser> selectAll();

    @Update({
            "update zhangyankun_spring_user",
            "set name = #{name,jdbcType=VARCHAR},",
            "psd = #{psd,jdbcType=VARCHAR},",
            "modif_time = #{modifTime,jdbcType=TIMESTAMP},",
            "domain = #{domain,jdbcType=VARCHAR}",
            "where email = #{email,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(ZhangyankunSpringUser record);
}